import 'package:bot_toast/bot_toast.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:easy_video/controller/app_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:easy_video/routes/routes.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await AppController().init();

  EasyRefresh.defaultHeaderBuilder = () => ClassicHeader(
        failedText: "刷新失败",
        dragText: "继续拖拽刷新",
        showMessage: false,
        readyText: "正在请求更新中...",
        processingText: "正在处理中...",
        processedText: "刷新完成",
        noMoreText: "没有更多的数据了",
        armedText: "松开立即刷新",
      );

  EasyRefresh.defaultFooterBuilder = () => ClassicFooter(
        failedText: "加载失败",
        dragText: "继续拖拽加载数据",
        showMessage: false,
        processingText: "正在处理中...",
        processedText: "加载完成",
        readyText: "正在加载中...",
        noMoreText: "没有更多的数据了",
        armedText: "松开立即加载",
      );

  runApp(
    GetMaterialApp(
      defaultTransition: Transition.rightToLeftWithFade,
      initialRoute: "/",
      theme: ThemeData(
        primaryColor: Colors.white,
        scaffoldBackgroundColor: Colors.white,
        appBarTheme: AppBarTheme(
          backgroundColor: Colors.white,
        ),
      ),
      builder: BotToastInit(),
      navigatorObservers: [BotToastNavigatorObserver()],
      getPages: Routes.Pages,
    ),
  );

  WidgetsBinding.instance.addPostFrameCallback((_) {
    AppController().loadUser();
  });
}
